package com.boss.salary.service.impl;

import com.boss.common.entity.PageDTO;
import com.boss.common.util.DateUtils;
import com.boss.framework.dto.PaginationDTO;
import com.boss.salary.dao.ISalPostGradeLevelDao;
import com.boss.salary.entity.SalPostGradeLevel;
import com.boss.salary.service.ISalPostGradeLevelService;
import com.boss.sys.utils.SysUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class SalPostGradeLevelServiceImplImpl implements ISalPostGradeLevelService {

    @Autowired
    private ISalPostGradeLevelDao iSalPostGradeLevelDao;

    @Override
    public PageDTO<Map<String, Object>> querySalPostGradeLevelPage(PaginationDTO paginationDTO, Map<String, Object> queryParam) {
        List<Map<String, Object>> map = iSalPostGradeLevelDao.querySalPostGradeLevelPage(paginationDTO, queryParam);
        int total = iSalPostGradeLevelDao.querySalPostGradeLevelCount(queryParam);
        PageDTO<Map<String, Object>> PageDTO = new PageDTO<>();
        PageDTO.setRows(map);
        PageDTO.setTotal(total);
        return PageDTO;
    }

    @Override
    public List<Map<String, Object>> querySalPostGradeLevelAll(Map<String, Object> queryParam) {
        return iSalPostGradeLevelDao.querySalPostGradeLevelAll(queryParam);
    }

    @Override
    public int queryDataByCode(String type, String code) {
        return iSalPostGradeLevelDao.queryDataByCode(type, code);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void insertSalPostGradeLevel(SalPostGradeLevel salPostGradeLevel) {
        salPostGradeLevel.setId(SysUtils.generateGuid());
        salPostGradeLevel.setCreateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        salPostGradeLevel.setUpdateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        iSalPostGradeLevelDao.insertSalPostGradeLevel(salPostGradeLevel);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateSalPostGradeLevel(SalPostGradeLevel salPostGradeLevel) {
        salPostGradeLevel.setUpdateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        iSalPostGradeLevelDao.updateSalPostGradeLevel(salPostGradeLevel);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteSalPostGradeLevel(String id) {
        iSalPostGradeLevelDao.deleteSalPostGradeLevel(id);
    }

}
